{% extends "business/customer.html" %}
{% block content %}

<nav aria-label="Page navigation">
  <ul class="pagination">
    <li>
      <a href="{% url "list_page_customer" prev_page %}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    {% for c in columns %}
        {% if c == active_page %}
            <li class="active"><a href="{% url "list_page_customer" c %}">{{ c }}</a></li>
        {% else %}
            <li><a href="{% url "list_page_customer" c %}">{{ c }}</a></li>
        {% endif %}
    {% endfor %}
    <li>
      <a href="{% url "list_page_customer" next_page %}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>

<table class="table table-hover table-condensed table-bordered">
    <thead>
        <tr>
            <td bgcolor="#C9C9C9">客户ID</td>
            <td bgcolor="#C9C9C9">客户名称</td>
            <td bgcolor="#C9C9C9">客户地址</td>
            <td bgcolor="#C9C9C9">联系人</td>
            <td bgcolor="#C9C9C9">联系电话</td>
            <td bgcolor="#C9C9C9">联系邮箱</td>
            <td bgcolor="#C9C9C9">客户详情</td>
            <td bgcolor="#C9C9C9">操作</td>
        </tr>
    </thead>
    <tbody>
    {% for customer in customers %}
        <tr class="success">
            <td><a href="{% url "show_customer" customer.id %}">{{ customer.id }}</a></td>
            <td><a href="{% url "show_customer" customer.name %}">{{ customer.name }}</a></td>
            <td>{{ customer.address }}</td>
            <td>{{ customer.contact }}</td>
            <td>{{ customer.telenumber }}</td>
            <td>{{ customer.email }}</td>
            <td><a href="{% url "show_customer" customer.id %}">查看详情</a></td>
            <td><button type="button" class="btn btn-primary btn-xs" id="Customer_{{ customer.id }}">删除</button></td>
        </tr>

        <script>
            $(function () {
                $("#Customer_{{ customer.id }}").click(function () {
                    if(confirm("确定删除 客户名称: {{ customer.name }} 客户? 该客户的订单和ticket信息也将被一起删除。")){
                        $.get("/business/del_customer?customer_id={{ customer.id }}", function () {
                            window.location.replace("/business");
                        });
                    }
                })
            })
        </script>
    {% endfor %}
    </tbody>
</table>

<nav aria-label="Page navigation">
  <ul class="pagination">
    <li>
      <a href="{% url "list_page_customer" prev_page %}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    {% for c in columns %}
        {% if c == active_page %}
            <li class="active"><a href="{% url "list_page_customer" c %}">{{ c }}</a></li>
        {% else %}
            <li><a href="{% url "list_page_customer" c %}">{{ c }}</a></li>
        {% endif %}
    {% endfor %}
    <li>
      <a href="{% url "list_page_customer" next_page %}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>
{% endblock %}